<#include "/common/dialogbox.html">
<@header>
</@header>
<@body>
<div class="x_content">
	 <form class="form-horizontal form-label-left" role="form" method="post" action="${ctx}/system/menu/doEdit" id="menuEditForm">
	   	<input type="hidden" name="id" value="${(sysMenu.id)!}" />
	    <div class="form-group">
	      	<label class="control-label col-md-2 col-sm-2 col-xs-12">
	      		目录名称 <span class="required">*</span>
      		</label>
      		<div class="col-md-9 col-sm-9 col-xs-12">
	     		<input type="text" name="menuName" class="form-control" value="${(sysMenu.menuName)!}" placeholder="请输入目录名称" required>
	     	</div>
	    </div>
	    <div class="form-group">
	      	<label class="control-label col-md-2 col-sm-2 col-xs-12">
	      		目录排序 <span class="required">*</span>
      		</label>
	      	<div class="col-md-9 col-sm-9 col-xs-12">
	     		<input type="text" name="sort" class="form-control" value="${(sysMenu.sort)!}"  placeholder="请输入排序" required>
	     		<span class="help-block m-b-none"><i class="fa fa-info-circle"></i>第一层级目录顺序</span>
	     	</div>
	    </div>
	    <div class="form-group">
	      	<label class="control-label col-md-2 col-sm-2 col-xs-12">
	      		目录图标 <span class="required">*</span>
      		</label>
      		<div class="col-md-9 col-sm-9 col-xs-12">
      			<span class="form-control">当前图标为：<i id="dirIcon" class="${(sysMenu.icon)!}"></i>
					<a href="javascript:void(0);" onclick="selectIcon(1)" class="pull-right">
						 点击选取图标
					</a>
				</span>
				<input type="hidden" class="form-control" name="icon" id="folderIcon" value="${(sysMenu.icon)!}">
	     	</div>
	    </div>
	</form>
</div>
</@body>
<@footer>
<script type="text/javascript">
	function selectIcon(type) {
		var layerIndex = parent.layer.getFrameIndex(window.name);
		parent.layer.open({
			type : 2,
			title : '选取图标',
			closeBtn : 1,
			anim : -1,
			isOutAnim : false,
			shadeClose : false,
			shade : 0.3,
			area : [ '95%', '90%' ],
			content : '/system/menu/toicon',
			btn : [ '确定', '取消' ],
			yes : function(index, layero) {
				var iframeWin = layero.find('iframe')[0];
				iframeWin.contentWindow.submitHandler(index,layero);
			},
			success : function(layero, index) {
				var body = parent.layer.getChildFrame('body', index);
				body.find("#sid").attr("iconType", type + "," + layerIndex);
			}
		});
	}

	function submitHandler() {
		if ($("#menuEditForm").validate().form()) {
			var formData = $("#menuEditForm").serialize();
			$.ajax({
				url : $("#menuEditForm").attr('action'),
				type : 'POST',
				dataType: "json",
				data : formData,
				success : function(data) {
					if (data.code == 200) {
						if (data.msg) {
							parent.layer.msg(data.msg, {
								icon : 1
							});
						} else {
							parent.layer.msg('提交成功', {
								icon : 1
							});
						}
						window.parent.location.reload();
						parent.layer.closeAll('iframe');
					} else {
						layer.msg(data.msg, { icon : 2 });
					}
				}
			});
		}
	}
</script>
</@footer>
